<?php
namespace app\api\controller\v1;
use think\Db;
use think\Request;


class Talk extends Base
{
	public function _initialize()
	{
		parent::_initialize();
//        $this->IsLogin(); //验证登录

	}

    public function talk_title(){
        $list = Db::name('talk_title')->where('is_delete_time',0)->select();
        $return['code'] = 0;
        $return['msg'] = '获取数据成功';
        $return['talk_list'] = $list;
        echo json_encode($return);
    }
    public function send_talk(Request $request){
        $param = $request->param();
        $user = $this->user;
        $insert['user_id'] = $user['id'];
        $insert['techn_id'] = $param['techn_id'];
        $insert['order_id'] = $param['order_id'];
        $insert['service_level'] = $param['xing'];
        $insert['title_ids'] = json_encode($param['list']);
        $insert['content'] = $param['content'];
        $insert['add_time'] = time();

//        $insert['user_id'] = 6879;
//        $insert['techn_id'] = 299;

        if (!empty($param['list'])){
            $result = Db::name('talk')->insert($insert);
            if ($result){
                Db::name('order')->where('id',$param['order_id'])->update(['is_talk'=>1]);
                $return['code'] = 0;
                $return['msg'] = '评价成功';
            }

        }else{
            $return['code'] = -1;
            $return['msg'] = '请勾选标签';
        }
        echo json_encode($return);
    }

    public function talk_list(){
        $list = Db::name('talk')->where('techn_id',299)->where('delete_time',0)->select();
        $return['code'] = 0;
        $return['msg'] = '获取成功';
        $return['data'] = $list;
        return $return;
    }
    
}